-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
util: improve performance of normalizeEncoding #50721
util: improve performance of normalizeEncoding #50721
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are not performing the same operation, if enc
is not a string, it will throw an error.
String.prototype.toLowerCase.call(undefined, [])
So we should stringify when enc
is not string and then perform toLowerCase
.
What you can do is add a slow path of stringify only when enc
is not a string, so maybe we can keep the fast-path with these new improvements.
Also, let's wait for the Benchmark CI results:
https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1471/
Thanks for your advise. But |
@zhenweijin You are right, my example was wrong. In this case, I think this change is safe to introduce. Benchmark Result:
|
@zhenweijin Thanks for the PR, I updated the description to use the Benchmark CI Results. |
Landed in daf723a |
PR-URL: #50721 Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
PR-URL: nodejs#50721 Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
PR-URL: #50721 Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
PR-URL: #50721 Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Improve performance of
normalizeEncoding
by using primordial.Benchmark Results: